<?php
	session_start();
	require_once("globals.php");
	require_once("functions.php");	
	$action = $_GET["action"];
	switch($action) {
		case "displayMainForm" :
			require_once("template_main_form.php");
			break;
		case "displaySensorsForm" :
			foreach ($_POST as $key=>$value) {
				$_SESSION[$key] = $value;
			}
			require_once("template_sensors_form.php");
			break;
		case "displaySensorsForm2" :
			foreach ($_POST as $key=>$value) {
				$_SESSION[$key] = $value;
			}			
			require_once("template_sensors_form2.php");
			break;
		case "displayObjectsForm" :
			foreach ($_POST as $key=>$value) {
				$_SESSION[$key] = $value;
			}			
			require_once("template_objects_form.php");
			break;
		case "displayObjectsForm2" :
			foreach ($_POST as $key=>$value) {
				$_SESSION[$key] = $value;
			}
			require_once("template_objects_form2.php");
			break;
		case "generateHouseXML" :
			foreach ($_POST as $key=>$value) {
				$_SESSION[$key] = $value;
			}			
			generateHouseXMLFile();
			$_SESSION = array();
			session_destroy();
			header("Location: ".$_SERVER[PHP_SELF]."?action=displayMainForm" );
			break;
		case "displayFamilyForm" :
			require_once("template_family_form.php");
			break;
		case "generateFamilyXML" :
			generateFamilyXMLFile();
			header("Location: ".$_SERVER[PHP_SELF]."?action=displayFamilyForm" );
			break;
		default:
			require_once("template_main_form.php");
			break;
	}
?>